<template>
   <div class="app-container">
	   <!-- 基本资料 -->
	   <div class="bgWhite radius8">
		   <div class="border-bottom p25">
			   <span class="fb fs16">{{type == 0 ? '基本资料' : '修改密码'}}</span>
		   </div>
		   <div class="p30" v-if="type == 0">
			   <userAvatar />
			   <userInfo :user="state.user" />
		   </div>
		   <div class="p30" v-else>
			   <resetPwd />
		   </div>
		</div>   
   </div>
</template>

<script setup name="Profile">
import userAvatar from "./userAvatar";
import userInfo from "./userInfo";
import resetPwd from "./resetPwd";
import { getUserProfile } from "@/api/system/user";
import { useRoute,onBeforeRouteUpdate } from 'vue-router'; 
import {ref, watch} from "vue";
const {
		proxy
	} = getCurrentInstance();
const route = useRoute()
const type = ref(1);
type.value = route.params.id

const activeTab = ref("userinfo");
const state = reactive({
  user: {},
  roleGroup: {},
  postGroup: {}
});

function getUser() {
  getUserProfile().then(response => {
    state.user = response.data;
	state.user.roleGroup = response.roleGroup;
	state.user.postGroup = response.postGroup;
    state.roleGroup = response.roleGroup;
    state.postGroup = response.postGroup;
  });
};

getUser();
</script>
